Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Displaying Rendered • View rawDownload


nomadnet/examples/messageboard/messageboard.mu cbc670d6b0773e398e765c0ce43994c70fcdde0f (cbc670d6) Text, 1.19 KB

import time
import os
import RNS.vendor.umsgpack as msgpack

message_board_peer = 'please_replace'
userdir = os.path.expanduser("~")

if os.path.isdir("/etc/nomadmb") and os.path.isfile("/etc/nomadmb/config"):
configdir = "/etc/nomadmb"
elif os.path.isdir(userdir+"/.config/nomadmb") and os.path.isfile(userdir+"/.config/nomadmb/config"):
configdir = userdir+"/.config/nomadmb"
else:
configdir = userdir+"/.nomadmb"

storagepath = configdir+"/storage"
if not os.path.isdir(storagepath):
os.makedirs(storagepath)

boardpath = configdir+"/storage/board"

print('NomadNet Message Board')

print('-')
print('')
print("")
print("To add a message to the board just converse with the NomadNet Message Board at lxmf@{}".format(message_board_peer))
time_string = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
print("Last Updated: {}".format(time_string))
print("")
print('>Messages')
print(" Date Time Username Message")
f = open(boardpath, "rb")
board_contents = msgpack.unpack(f)
board_contents.reverse()

for content in board_contents:
print("{}".format(content.rstrip()))
print("")

f.close()

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────